{{extend name="layout/base-html"}}

{{block name="body"}}
<style>
    /** 行高自适应 **/
    .layui-table-cell {
        height: inherit;
    }
</style>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">

                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="keyWord" placeholder="请输入请求地址|ip地址" autocomplete="off"
                                   class="layui-input"></div>


                        <div class="layui-inline layui-show-xs-block">
                            <select name="method">
                                <option value="">全部请求</option>
                                {{volist name="methods" id="v"}}
                                <option value="{{$v}}">{{$v}}</option>
                                {{/volist}}
                            </select>
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <select name="user_id">
                                <option value="">管理员列表</option>
                                {{volist name="admins" id="v"}}
                                <option value="{{$v.id}}">{{$v.username}}</option>
                                {{/volist}}
                            </select>
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="search">
                                <i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>

                </div>
                <div class="layui-card-body ">
                    <table id="table" lay-filter="table"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="path">
    <span>{{= d.path}}</span>
</script>

<script type="module">
    import { rain } from "/static/admin/js/app.js";

    layui.use(['table', 'laydate'], () => {
        let table = layui.table,
            form = layui.form;

        // 表格筛选
        table.render({
            ...rain.config.table

            ,toolbar: '#action-toolbar'
            ,defaultToolbar: []

            ,cols: [[ //表头
                {field: 'id', title: 'ID', sort: true}
                ,{field: 'username', title: '管理员名称'}
                ,{field: 'path', title: '请求地址', templet: '#path'}
                ,{field: 'method', title: '请求方式'}
                ,{field: 'ip', title: 'ip地址'}
                ,{field: 'input', title: '请求参数'}
                ,{field: 'create_time', title: '创建时间'}
            ]],
            id: 'table-reload',
        });

        // 初始化配置
        rain.tableAction.init = { form, table };

        // 筛选
        rain.tableAction.search('table-reload');
    });


</script>
{{/block}}
